require('../css/sportData.less');
require('../fonts/iconfont.css')
const echarts = require('echarts')

//返回点击事件
let iconfont = document.querySelector('.iconfont')
iconfont.addEventListener('click', function () {
    location.href = "../page/about.html"
})

let user = JSON.parse(localStorage.getItem('user'))
let calorieTotal = document.querySelector('.calorieTotal')
let timeTotal = document.querySelector('.timeTotal')
let calorie_total = document.querySelector('.calorie_total')
let dayTotal = document.querySelector('.dayTotal')
let cdayTotal = document.querySelector('.cdayTotal')
let img = document.querySelector('img')

//渲染数据
$http.get('/users/mysportsBadge?userId=' + user.userId, function (res) {
    img.src = res.data.user.imgurl
    timeTotal.textContent = res.data.sports.times
    dayTotal.textContent = res.data.sports.times
    calorieTotal.textContent = res.data.sports.calorie
    calorie_total.textContent = res.data.sports.calorie
    cdayTotal.textContent = res.data.sports.punchin
})





var myChart = echarts.init(document.querySelector('.ECharts'));

// 指定图表的配置项和数据
var option = {
    title: {
        text: '近七天运动时长',
        left: 20
    },
    tooltip: {},
    legend: {
        data: ['销量']
    },
    xAxis: {
        data: ["11-5", "11-6", "11-7", "11-8", "11-9", "11-10", "11-11"]
    },
    yAxis: {},
    series: [{
        type: 'bar',
        data: [30, 58, 32, 120, 90, 90, 60]
    }]
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);




//柄图
var myChart1 = echarts.init(document.querySelector('.ECharts1'));

var option1 = {
    title: {
        text: '运动分类',
        left: 'center'
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        orient: 'vertical',
        left: 'left',
    },
    series: [{
        name: '运动分类',
        type: 'pie',
        radius: '50%',
        data: [{
                value: 25,
                name: '跑步'
            },
            {
                value: 35,
                name: '骑行'
            },
            {
                value: 40,
                name: '训练'
            },
        ],
        emphasis: {
            itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
        }
    }]
};
myChart1.setOption(option1)